package com.atguigu.staservice.controller;


import com.atguigu.commonutils.R;
import com.atguigu.staservice.UcenterClient;
import com.atguigu.staservice.service.StatisticsDailyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * <p>
 * 网站统计日数据 前端控制器
 * </p>
 *
 * @author testjava
 * @since 2022-08-14
 */
@RestController
@RequestMapping("/staservice/sta")
@CrossOrigin
public class StatisticsDailyController {

    @Autowired
    private StatisticsDailyService staService;

    //统计某一天的注册人数，往数据库中加数据
    @PostMapping("registerCount/{day}")
    public R registerCount(@PathVariable String day) {
        System.out.println("统计某一天的注册人数，往数据库中加数据方法开始执行...");
        staService.registerCount(day);
        return R.ok();
    }

    //图表显示，返回部分数据，日期Json数据，数量Json数据
    @GetMapping("showData/{type}/{begin}/{end}")//{统计因子，开始时间，结束时间}
    public R showData(@PathVariable String type,@PathVariable String begin,
                      @PathVariable String end) {
        //调用方法，把值传进去
        Map<String,Object> map = staService.getShowData(type,begin,end);
        return R.ok().data(map);
    }

}

